package com.bawei.newsapplication.view.activity.channel

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import androidx.lifecycle.Observer
import com.bawei.newsapplication.R
import com.bawei.newsapplication.base.BaseActivity
import com.bawei.newsapplication.databinding.ActivityProductDetailBinding
import com.bawei.newsapplication.viewmodel.ProductListViewModel
import com.bumptech.glide.Glide

/**
 * 作者: 谢庆平
 * 时间: 2024/10/31 9:14
 * 描述:商品商城详情
 */
class ProductDetailActivity : BaseActivity<ProductListViewModel,ActivityProductDetailBinding>(R.layout.activity_product_detail) {
    override fun initView() {
        //TODO 获取商品id
        val intExtra = intent.getIntExtra("productId", 0)
        mViewModel.getProductDetail(intExtra)
        //TODO 获取回答id
//        val answerId = intent.getIntExtra("answerId", 0)
//        mViewModel.getProductDetail(answerId)
    }

    override fun dataObserve() {
         mViewModel.productDetailData.observe(this, Observer {
             Glide.with(this).load(it.result.productPic).into(mDataBinding.productPic)
             mDataBinding.exchangeEndTime.text="兑换截止时间:"+it.result.exchangeEndTime+""
             mDataBinding.exchangeRules.text="兑换规则:"+it.result.exchangeRules
             mDataBinding.inventoryNum.text="库存:"+it.result.inventoryNum+""
             mDataBinding.productIntroduce.text="商品介绍:"+it.result.productIntroduce
             mDataBinding.productName.text="商品名称:"+it.result.productName
             mDataBinding.productPrice.text="￥"+it.result.productPrice+""
             mDataBinding.soldNum.text="已售:"+it.result.soldNum+""
         })
    }

}